<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : userManagement.xsl
    Created on : June 10, 2013, 2:33 PM
    Author     : Thuc
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html"/>
    <xsl:param name="currentId"></xsl:param>
    <!-- TODO customize transformation rules
         syntax recommendation http://www.w3.org/TR/xslt
    -->
    <xsl:template match="/">
        <table class="userTable">
            <tr>
                <th>ID</th>
                <th>Tên đăng nhập</th>
                <th>Tên đầy đủ</th>
                <th>Email</th>
                <th>Phân quyền</th>
                <th>Tình trạng</th>
            </tr>
            <xsl:for-each select="//user">
                <xsl:if test="userId != $currentId">
                <tr>
                    <td>
                        <xsl:value-of select="userId"/>
                    </td>
                    <td>
                        <xsl:value-of select="username"/>
                    </td>
                    <td>
                        <xsl:value-of select="fullName"/>
                    </td>
                    <td>
                        <xsl:value-of select="email"/>
                    </td>
                    <td>
                        <xsl:choose>
                            <xsl:when test="isAdmin = 'true'">
                                <form action="setPermission.action" method="post">
                                    <input type="hidden" name="userId">
                                        <xsl:attribute name="value">
                                            <xsl:value-of select="userId"/>
                                        </xsl:attribute>
                                    </input>
                                    <input type="hidden" name="status" value="false" />
                                    <input type="submit" value="Người dùng" style="background-color:#df4b4b"/>
                                </form>
                            </xsl:when>
                            <xsl:otherwise>
                                <form action="setPermission.action" method="post">
                                    <input type="hidden" name="userId">
                                        <xsl:attribute name="value">
                                            <xsl:value-of select="userId"/>
                                        </xsl:attribute>
                                    </input>
                                    <input type="hidden" name="status" value="true" />
                                    <input type="submit" value="Admin" style="background-color:#6293ec"/>
                                </form>
                            </xsl:otherwise>
                        </xsl:choose>
                    </td>
                    <td>
                        <xsl:choose>
                            <xsl:when test="isActive= 'true'">
                                <form action="setActivation.action" method="post">
                                    <input type="hidden" name="userId">
                                        <xsl:attribute name="value">
                                            <xsl:value-of select="userId"/>
                                        </xsl:attribute>
                                    </input>
                                    <input type="hidden" name="status" value="false" />
                                    <input type="submit" value="Khóa" style="background-color:#df4b4b"/>
                                </form>
                            </xsl:when>
                            <xsl:otherwise>
                                <form action="setActivation.action" method="post">
                                    <input type="hidden" name="userId">
                                        <xsl:attribute name="value">
                                            <xsl:value-of select="userId"/>
                                        </xsl:attribute>
                                    </input>
                                    <input type="hidden" name="status" value="true" />
                                    <input type="submit" value="Mở khóa" style="background-color:#6293ec"/>
                                </form>
                            </xsl:otherwise>
                        </xsl:choose>
                    </td>
                </tr>
                </xsl:if>
            </xsl:for-each>
        </table>
    </xsl:template>
</xsl:stylesheet>
